<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>JOB配置</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>
<!-- 你的HTML代码 -->
<div class="demoTable">
    <form class="layui-form">

        <div class="layui-inline">
            <label class="layui-form-label">日期：</label>
            <div class="layui-input-block">
                <input type="text" name="date"  id="date"   class="layui-input" >
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">任务名称：</label>
            <div class="layui-input-block">
                <input class="layui-input" name="jobName"  autocomplete="off">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">报表名称：</label>
            <div class="layui-input-block">
                <input class="layui-input" name="reportName"  autocomplete="off">
            </div>
        </div>

        <button class="layui-btn" lay-submit lay-filter="reload"  >搜索</button>
    </form>
    <hr>
</div>

<table class="layui-hide" id="LAY_table_user" lay-filter="LAY_table_user"></table>

<script type="text/html" id="toolbarJobCfg">
    <a class="layui-btn layui-btn-xs" lay-event="dowLoad">下载</a>
</script>

<script src="../layui/layui.all.js"></script>
<script>

    var tableOption =  {
                elem: '#LAY_table_user'
                ,data:[]
                ,cols: [[
                     {field:'physicalName', title: '文件列表',sort: true}
                    ,{title: '操作',toolbar:"#toolbarJobCfg" ,width:180 }
                ]]
                ,id: 'LAY_table_user'
                ,page: true
                ,height: 'full-230'
            }

    //由于模块都一次性加载，因此不用执行 layui.use() 来加载对应模块，直接使用即可：
            ;!function(){
        var layer = layui.layer
        var form = layui.form;
        var table = layui.table;
        var $ = layui.$
        var laydate = layui.laydate;

        laydate.render({
            elem: '#date' ,//指定元素
            type:'date',
            format:"yyyy-MM-dd",
            value:new Date()
        });

        var jobCfgUtil = {
            query:function(table,tableOption,obj){
                $.getJSON("../xxdsqljob/jobReportFile",obj||{}, function(rst){
                    if(rst.code!=0){
                        layer.alert(rst.msg)
                    }else{
                        tableOption.data = rst.data
                        table.render(tableOption)
                    }
                })
            }
        }


        table.on('tool(LAY_table_user)',function(obj){
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event;
            switch (layEvent){
                case "dowLoad":
                    var fileName = data.fileName
                    var tempFile = data.physicalName
                    window.open("../xxdsqljob/dowLoadFile?fileName="+fileName+"&tempFile="+tempFile);
                    break;
            }
            return false
        })


        form.on("submit(reload)",function(obj){
            //console.log(obj.field)
            jobCfgUtil.query(table,tableOption,obj.field)
            return false
        })

        jobCfgUtil.query(table,tableOption)
    }();

</script>

</body>
</html>
